<?php
$this->breadcrumbs=array(
	'Sensors'=>array('admin'),
	'管理',
);


Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$(this).toggleClass('collapse');
	$('fieldset').toggleClass('collapsed');
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('sensors-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<div id="page-header">
	<h1>管理<?php echo $this->moduleName; ?></h1>
    <div id="page-options">
	<?php $this->renderPartial('_menu',array(
    'model'=>$model,
    )); ?>
    </div>
</div>

<?php $form=$this->beginWidget('CActiveForm', array(
	'action'=>Yii::app()->createUrl($this->route),
	'method'=>'get',
	'htmlOptions'=>array(
		'class' => 'form',
	),
)); ?>

</fieldset>
<fieldset class="grey inline">
  <legend><?php echo CHtml::link('串口参数设置','#',array('class'=>'search-button')); ?></legend>
  
 <div class = 'row'>
<?php echo $form->label($setting,'BAUD_V'); ?>
<label><?php echo $form->dropDownList($setting,'BAUD_V',array('19200','1200', '2400', '4800', 
'9600', '14400', '38400', '56000', '57600','1152000','128000','256000')); ?>
</label>
<?php echo $form->label($setting,'DATABITS_N'); ?>
<label><?php echo $form->dropDownList($setting,'DATABITS_N',array('8', '7', '6','5')); ?>
</label>
</div>

<div class = 'row'>
<?php echo $form->label($setting,'STOPBITS_N'); ?>
<label><?php echo $form->dropDownList($setting,'STOPBITS_N',array('1', '2')); ?>
</label>
<?php echo $form->label($setting,'PARITY_V'); ?>
<label><?php echo $form->dropDownList($setting,'PARITY_V',array('NONE', 'ODD', 'EVEN')); ?>
</label>
</div>
</fieldset>
<?php $this->endWidget(); ?>

<?php 

$this->renderPartial('_search',array(
'model'=>$model,
)); 

?>

<?php //echo CHtml::button('开始采集', array('submit' => array('Sensors/command'),'class'=>'button blue inline','style'=>'width:100px;')); ?>



<?php 
echo CHtml::button('采集结果', array(
	'data-url' => 'index.php?r=sensors/results',
	'class'=>'button blue inline',
	'style'=>'width:100px;',
	'onclick'=>'window.getResult(this)',
)); 
?>

<section class="grid_9" id="dashtabs">
<div class="box-header">
  <?php echo $this->moduleName."列表"; ?></div>
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'sensors-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		array(
			'class'=>'CCheckBoxColumn',
			'selectableRows'=>2,
			'checkBoxHtmlOptions'=>array('class'=>'art-checkbox'),
			'id'=>'column_chk',		
		),
		'RECORD_ID',
		'SENSORNAME_V',
//		'GROUPNAME_V',
array(
		'name' => 'GROUPNAME_V',
		'value' => '$data->BTBATTERYS->GROUPNAME_V',
),
array(
		'name' => 'BASENAME_V',
		'value' => '$data->MTSYSBASE->BASE_NAME',
),
//		'BASENAME_V',
//		'PROVINCENAME_V',
//		'CITYNAME_V',
//		'COUNTRYNAME_V',
		'SENSOR_SETUP_NAME_V',
		'SENSOR_N',
		'BATTERYNUM_N',
		'SENSOR_ADDR_N',
		'COM_N',
		'IP_V',
		'SETUP_D',
		'REMARK_V',
		array(
			'class'=>'CButtonColumn',
            'viewButtonImageUrl'=> Yii::app()->request->baseUrl.'/css/img/icons/16/page.png',            
            'updateButtonImageUrl'=> Yii::app()->request->baseUrl.'/css/img/icons/16/page_edit.png',
            'deleteButtonImageUrl'=> Yii::app()->request->baseUrl.'/css/img/icons/16/page_delete.png',
		),
	),
    'template'=>'{items}{summary}{pager}',
    'htmlOptions'=>array(
    	'class'=>'cgridview'
    ),
    'cssFile' => Yii::app()->request->baseUrl.'/css/widgets/cgridview.css',
)); ?>
</section>

<?php
Yii::app()->clientScript->registerScriptFile('js/pager.sensors.js', CClientScript::POS_END);
?>
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id'=>'page_result',
    // additional javascript options for the dialog plugin
    'options'=>array(
        'title'=>'查看采集结果',
        'autoOpen'=>false,
		'width'=>'80%',
		'height'=>'600'
    ),
));
?>
<iframe id="result" width="100%" height="100%"></iframe>
<?php
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
<script>
function getResult(ele){
	$("iframe#result").attr("src",$(ele).attr("data-url")); 
	$("#page_result").dialog("open"); 
	return false;	
}
</script>